﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="mapdata.aspx.cs" Inherits="_70C.activitys.mapdata" %>


<!DOCTYPE html>
<html lang="en">
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=RYvh3uywSDQYzaoIOiFntTnh"></script>
        <script type="text/javascript" src="http://res.70c.com/js/jquery-1.8.3.min.js"></script>
    <style>
    .leftdiv{ width:302px; float:left}
        .rightdiv {
            width: 302px;
            float: left;
            height: 355px;
            background-color: #f7f7f7;
        }
        .tj_right ul {
            -webkit-padding-start: 0;
            padding: 0;
            margin: 10px 0 0 10px;
        }
    .tj_right  ul li{ font-size:11px;}
     .tj_right ul li input[type=text]{ height:18px}
       
         .tj_right_bg table {
            margin-top: 10px;
        }
     #allmap {width: 300px;height: 300px;}
     .tj_right_bg{font-size:11px}
     .tj_right_bg ul{ margin-top:0px}
     .pull-right{ padding-top:5px}
     .u-page a{ padding-left:5px}
        .tj_right ul li {
            list-style: none;
            height: 28px;
            line-height: 28px;
            display: inline-block;
            color: #666;
            font-size: 14px;
        }
        .tj_right ul .li-name {
            width: 24%;
            padding-left: 20px;
        }
        .tj_right ul .li-input {width: 62%;}
		.tj_right ul .li-input2 {width: 26%;}
		.tj_right ul .li-input3 {width: 26%;padding-left:1px}
     .tj_right div{ white-space:nowrap; float:left;}    
     .openera{ cursor:pointer; color: #68c500;}
        #btnadd {
            background-color: #68c500;
            color: #ffffff;
            border: 0;
            height: 30px;
            width: 100px;
            border-radius: 3px;
            font-size: 14px;
            margin-left: 13px;
        }
        #btnsave, #reset {
            background-color: #68c500;
            color: #ffffff;
            border: 0;
            height: 30px;
            width: 114px;
            border-radius: 3px;
            margin-top: 7px;
            font-size: 14px;
        }  
#btndel{background-color: #ccc; color:#ffffff; border:0;height: 30px;
width: 60px;border-radius: 3px;
}
       
        .search-address {
            background-color: #68c500;
            color: #ffffff;
            border: 0;
            width: 80px;
            margin-top: 3px;
            height: 30px;
            border-radius: 3px;
        }
        .maplist {
            width: 100%;
            padding: 10px 5px 0 0;
        }
        .li-bottom-color p {
            margin: 0 10px;
            line-height: 20px;
            height: 20px;
            font-size: 14px;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
            width: 270px;
        }
#successTip{
margin-top: 0px;
color: #ffffff;
background-color: #68c500;
height: 65px;
padding-left: 10px;
line-height: 65px;
position: absolute;
opacity: 1;
z-index: 999;
border-radius: 5px;
width: 100%;
}
            .li-bottom-color p span {
                line-height: 20px;
                height: 20px;
                display: inline-block;
                font-size: 14px;
            }
       .li-bottom-color{ border-bottom: 1px solid #e6e6e6;
padding: 10px 0px;
margin: 0 10px;}
.li-bottom-color p .info{width: 80%; overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;}
      .divaddress img{margin-bottom: 10px;}
	 .divaddress{border:1px solid rgb(169, 169, 169);background-color: #ffffff;margin-top: 5px;height: 45px;}
    </style>
  
    
	<title></title>
	</head>
	<body style="margin:0px 0 0 0px"><input type="hidden" id="addressCount" value="0"/>
    <div style="width:302px;height:300px;">
    <div class="maplist" id="maplist" style="display:none">    
    <div><label class="checkall"  style="display:none"><input type="checkbox" id="allcheck" onclick="checkall();" /><span>全选</span></label> <input type="button" id="btnadd" onclick="    addmapdata();" value="添加店铺" /> <input id="btndel" type="button" value="删除" onclick="    addressDels();" style="font-size:11px;display:none" />  </div>
     <div class="tj_right_bg">
  <ul class="maplist">
</ul>
              

</div>
     </div>

    <div class="mapedit" id="mapedit" style="display:block">
	<p style="opacity:0" id="successTip">添加成功！</p>
    <div class="leftdiv"><div id="allmap"></div></div>
    <div class="rightdiv">
      <div class="tj_right">
               <form action="/index/mapdatasave" method="post">
               <ul>
               <li class="li-name">
               <input type="hidden" id="Id" />店铺名称：
               </li>
                   <li class="li-input">
                       <input type="text" style="width:161px;" id="name" name="name" placeholder="店铺名称" />
                   </li> 
                   <li class="li-name" style="text-align:right;">电话：</li>
                   <li class="li-input">
                       <input placeholder="联系电话" type="text" name="tel" id="tel" style="width:161px;" />
                   </li>
                   <li class="li-name">
                       所在省市：
                   </li>
                   <li class="li-input2">
                       <select style="width: 80px; height: 24px;color: #000; " name="Province" id="Province" class="prov" onchange="set_city(this, document.getElementById('city'));">
                           <option value="0">请选择</option>
                           <option value="北京">北京</option>
                           <option value="上海">上海</option>
                           <option value="天津">天津</option>
                           <option value="重庆">重庆</option>
                           <option value="河北省">河北省</option>
                           <option value="山西省">山西省</option>
                           <option value="辽宁省">辽宁省</option>
                           <option value="吉林省">吉林省</option>
                           <option value="黑龙江省">黑龙江省</option>
                           <option value="江苏省">江苏省</option>
                           <option value="浙江省">浙江省</option>
                           <option value="安徽省">安徽省</option>
                           <option value="福建省">福建省</option>
                           <option value="江西省">江西省</option>
                           <option value="山东省">山东省</option>
                           <option value="河南省">河南省</option>
                           <option value="湖北省">湖北省</option>
                           <option value="湖南省">湖南省</option>
                           <option value="广东省">广东省</option>
                           <option value="海南省">海南省</option>
                           <option value="四川省">四川省</option>
                           <option value="贵州省">贵州省</option>
                           <option value="云南省">云南省</option>
                           <option value="陕西省">陕西省</option>
                           <option value="甘肃省">甘肃省</option>
                           <option value="青海省">青海省</option>
                           <option value="内蒙古">内蒙古</option>
                           <option value="广西">广西</option>
                           <option value="西藏">西藏</option>
                           <option value="宁夏">宁夏</option>
                           <option value="新疆">新疆</option>
                           <option value="香港">香港</option>
                           <option value="澳门">澳门</option>
                           <option value="台湾">台湾</option>
                       </select>
                   </li>
                   <li class="li-input3">
                       <select class="city" style="width: 80px; height: 24px;color: #000; " name="City" id="city" onchange="citychange(this);">
                           <option value="">请选择</option>
                       </select>
                   </li>
                   <li class="li-name" style="text-align:right;">
                       详细地址：
                   </li>
                   <li class="li-input" >
				   <div class="divaddress">
                       <textarea id="address" style="width: 130px; height: 40px;border: none;" name="address" title="详细地址，填完点击“搜索地址”查看地址在地图上的位置是否正确" placeholder="详细地址，具体到街道门牌号"></textarea><img src="http://res.70c.com/scene-editor/images/suo.png" onclick="addressSearch();" /></div>
                   </li>               
                   <li style="padding-left: 20px;padding-top: 20px;">
                       <div>
                           <input type="button" onclick="submitForm();" class="sub" value="添加" id="btnsave" />  <input type="reset" style="margin-left: 10px;" class="sub" value="店铺列表" id="reset" onclick="    resetForm();" />  <input type="hidden" name="longitude" id="lng" value="" />
                           <input type="hidden" name="latitude" id="lat" value="" />
                       </div>
                   </li>
              </ul>
                
                  </form>
                </div>
             </div>
    </div>
    </div>
	</body>	
    <script language="javascript">

        var cities = new Object();
        cities['台湾'] = new Array('台北', '台南', '其他');
        cities['北京'] = new Array('北京');
        cities['上海'] = new Array('上海');
        cities['天津'] = new Array('天津');
        cities['重庆'] = new Array('重庆');
        cities['河北省'] = new Array('石家庄', '张家口', '承德', '秦皇岛', '唐山', '廊坊', '保定', '沧州', '衡水', '邢台', '邯郸');
        cities['山西省'] = new Array('太原', '大同', '朔州', '阳泉', '长治', '晋城', '忻州', '吕梁', '晋中', '临汾', '运城');
        cities['辽宁省'] = new Array('沈阳', '朝阳', '阜新', '铁岭', '抚顺', '本溪', '辽阳', '鞍山', '丹东', '大连', '营口', '盘锦', '锦州', '葫芦岛');
        cities['吉林省'] = new Array('长春', '白城', '松原', '吉林', '四平', '辽源', '通化', '白山', '延边');
        cities['黑龙江省'] = new Array('哈尔滨', '齐齐哈尔', '黑河', '大庆', '伊春', '鹤岗', '佳木斯', '双鸭山', '七台河', '鸡西', '牡丹江', '绥化', '大兴安');
        cities['江苏省'] = new Array('南京', '徐州', '连云港', '宿迁', '淮阴', '盐城', '扬州', '泰州', '南通', '镇江', '常州', '无锡', '苏州');
        cities['浙江省'] = new Array('杭州', '湖州', '嘉兴', '舟山', '宁波', '绍兴', '金华', '台州', '温州', '丽水');
        cities['安徽省'] = new Array('合肥', '宿州', '淮北', '阜阳', '蚌埠', '淮南', '滁州', '马鞍山', '芜湖', '铜陵', '安庆', '黄山', '六安', '巢湖', '亳州', '池州', '宣城');
        cities['福建省'] = new Array('福州', '南平', '三明', '莆田', '泉州', '厦门', '漳州', '龙岩', '宁德');
        cities['江西省'] = new Array('南昌', '九江', '景德镇', '鹰潭', '新余', '萍乡', '赣州', '上饶', '抚州', '宜春', '吉安');
        cities['山东省'] = new Array('济南', '聊城', '德州', '东营', '淄博', '潍坊', '烟台', '威海', '青岛', '日照', '临沂', '枣庄', '济宁', '泰安', '莱芜', '滨州', '菏泽');
        cities['河南省'] = new Array('郑州', '三门峡', '洛阳', '焦作', '新乡', '鹤壁', '安阳', '濮阳', '开封', '商丘', '许昌', '漯河', '平顶山', '南阳', '信阳', '周口', '驻马店');
        cities['湖北省'] = new Array('武汉', '十堰', '襄攀', '荆门', '孝感', '黄冈', '鄂州', '黄石', '咸宁', '荆州', '宜昌', '恩施', '襄樊');
        cities['湖南省'] = new Array('长沙', '张家界', '常德', '益阳', '岳阳', '株洲', '湘潭', '衡阳', '郴州', '永州', '邵阳', '怀化', '娄底', '湘西');
        cities['广东省'] = new Array('广州', '清远', '韶关', '河源', '梅州', '潮州', '汕头', '揭阳', '汕尾', '惠州', '东莞', '深圳', '珠海', '江门', '佛山', '肇庆', '云浮', '阳江', '茂名', '湛江', '中山');
        cities['海南省'] = new Array('海口', '三亚', '五指山市', '琼海市', '儋州市', '文昌市', '万宁市', '东方市', '定安县', '屯昌县', '澄迈县', '临高县', '白沙黎族自治县');
        cities['四川省'] = new Array('成都', '广元', '绵阳', '德阳', '南充', '广安', '遂宁', '内江', '乐山', '自贡', '泸州', '宜宾', '攀枝花', '巴中', '达川', '资阳', '眉山', '雅安', '阿坝', '甘孜', '凉山');
        cities['贵州省'] = new Array('贵阳', '六盘水', '遵义', '毕节', '铜仁', '安顺', '黔东南', '黔南', '黔西南');
        cities['云南省'] = new Array('昆明', '曲靖', '玉溪', '丽江', '昭通', '思茅', '临沧', '保山', '德宏', '怒江', '迪庆', '大理', '楚雄', '红河', '文山', '西双版纳');
        cities['陕西省'] = new Array('西安', '延安', '铜川', '渭南', '咸阳', '宝鸡', '汉中', '榆林', '商洛', '安康');
        cities['甘肃省'] = new Array('兰州', '嘉峪关', '金昌', '白银', '天水', '酒泉', '张掖', '武威', '庆阳', '平凉', '定西', '陇南', '临夏', '甘南');
        cities['青海省'] = new Array('西宁', '海东', '西宁', '海北', '海南', '黄南', '果洛', '玉树', '海西');
        cities['内蒙古'] = new Array('呼和浩特', '包头', '乌海', '赤峰', '呼伦贝尔盟', '兴安盟', '哲里木盟', '锡林郭勒盟', '乌兰察布盟', '鄂尔多斯', '巴彦淖尔盟', '阿拉善盟');
        cities['广西'] = new Array('南宁', '桂林', '柳州', '梧州', '贵港', '玉林', '钦州', '北海', '防城港', '南宁', '百色', '河池', '柳州', '贺州');
        cities['西藏'] = new Array('拉萨', '那曲', '昌都', '林芝', '山南', '日喀则', '阿里');
        cities['宁夏'] = new Array('银川', '石嘴山', '吴忠', '固原', '中卫');
        cities['新疆'] = new Array('乌鲁木齐', '克拉玛依', '喀什', '阿克苏', '和田', '吐鲁番', '哈密', '博尔塔拉', '昌吉', '巴音郭楞', '伊犁', '塔城', '阿勒泰');
        cities['香港'] = new Array('香港');
        cities['澳门'] = new Array('澳门');

        function set_city(province, city) {
            var pv, cv;
            var i, ii;
            pv = province.value;
            cv = city.value;
            city.length = 1;
            if (pv == '0') return;
            if (typeof (cities[pv]) == 'undefined') return;
            for (i = 0; i < cities[pv].length; i++) {
                ii = i + 1;
                city.options[ii] = new Option();
                city.options[ii].text = cities[pv][i];
                city.options[ii].value = cities[pv][i];
            }
            if (cities[pv].length == 1) {
                city.value = cities[pv][0];
                cityName = cities[pv][0];
                map.setCenter(cityName);
            }
        }

        function showNone(event) {
            var evt = event || window.event;
            $(evt.target).find(".edit").hide();
        }
        function showBlock(event) {
            var evt = event || window.event;
            $(evt.target).find(".edit").show();
        }

        function checkall() {
            var chkallchked = document.getElementById("allcheck").checked;
            var chk = document.getElementsByName("chk");
            for (var i = 0; i < chk.length; i++) {
                chk[i].checked = chkallchked;
            }
        }
        function GetQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) {
                return unescape(r[2]);
            }
            return null;
        };
        if (GetQueryString("tab") == "list" || document.getElementById("addressCount").value != 0) {
            resetForm();
        } else {
            addmapdata();
        }
        window.parent.document.getElementById('divditu_footer').style.display = "none";
        function editmap(Id, Name, Tel, Province, City, Address) {
            document.getElementById("maplist").style.display = "none";
            document.getElementById("mapedit").style.display = "block";
            window.parent.document.getElementById('divditu_footer').style.display = "none";
            document.getElementById("tel").value = Tel;
            document.getElementById("address").value = Address;
            document.getElementById("Province").value = Province;
            set_city(document.getElementById("Province"), document.getElementById("city"));
            document.getElementById("city").value = City;
            map.setCenter(City);
            document.getElementById("name").value = Name;
            document.getElementById("Id").value = Id;
            document.getElementById("btnsave").value = "保存";
            addressSearch();
        }
        function addmapdata() {
            document.getElementById("mapedit").style.display = "block";
            document.getElementById("maplist").style.display = "none";
            window.parent.document.getElementById('divditu_footer').style.display = "none";
            //divditu_footer
        }
        function resetForm() {
            document.getElementById("btnsave").value = "添加";
            document.getElementById("mapedit").style.display = "none";
            document.getElementById("maplist").style.display = "block";
            // window.parent.document.getElementById('divditu_footer').style.display = "block";
        }
        function addressDels() {
            if (confirm("是否确定删除？")) {
                var chks = document.getElementsByName("chk");
                var ids = "";
                for (var i = 0; i < chks.length; i++) {
                    if (chks[i].checked) {
                        ids += chks[i].value + ",";
                    }
                }
                if (ids == "") {
                    alertfun("请至少选择一个要删除的地址。");
                    return false;
                }
                var url = "/index/delmaps?ids=" + ids;
                var fun = function (data) {
                    if (data.indexOf("true") > 0) {
                        alertfun("删除成功")
                        location.reload();

                    } else {
                        alertfun("删除失败");
                    }
                }
                ajaxGet(url, fun);
            }
        }
        function delmap(id) {
            if (confirm("是否确定删除？")) {
                var url = "/index/delmap?id=" + id;
                var fun = function (data) {
                    if (data.indexOf("true") > 0) {
                        alertfun("删除成功");
                        location.reload();
                    } else {
                        alertfun("删除失败");
                    }
                }
                ajaxGet(url, fun);
            }
        }
        function ajaxGet(url, fun) {
            var req = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
            req.onreadystatechange = function () {
                if (req.readyState == 4) {
                    fun(req.responseText);
                }
            };
            req.open("GET", url, "false");
            req.send(null);
        }
        var Latitude = "";
        var Longitude = "";
        function submitForm() {
            var savetype = document.getElementById("btnsave").value;
            if (Latitude == "") {
                Latitude = document.getElementById("lat").value;
            }
            if (Longitude == "") {
                Longitude = document.getElementById("lng").value;
            }
            if (!Latitude) {
                alertfun("请先点击“搜索地址”给位置标注");
                return false;
            }
            var tel = document.getElementById("tel").value;
            if (!(/^(\d{10,11})|^((\d{7,8})|^(\d{5})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$/.test(tel))) {
                alertfun("电话号码格式不正确");

                document.getElementById("tel").focus();
                return false;
            }

            var address = document.getElementById("address").value;
            var province = document.getElementById("Province").value;
            var city = document.getElementById("city").value;
            var name = document.getElementById("name").value;
            var sceneID = GetQueryString("sceneID");
            var param = "tel=" + tel + "&address=" + encodeURIComponent(address) + "&province=" + encodeURIComponent(province) + "&city=" + encodeURIComponent(city) + "&name=" + encodeURIComponent(name) + "&sceneID=" + sceneID + "&Latitude=" + Latitude + "&Longitude=" + Longitude;
            var url = "/index/mapdatasave?" + param;
            if (savetype == "保存") {
                //编辑保存
                var id = document.getElementById("Id").value;
                url = "/index/mapdateedit?" + param + "&Id=" + id;
            }
            var fun = function (ret) {
                if (ret.indexOf('true') > 0) {
                    alertfun("保存成功！");


                    /*if(window.confirm("保存成功，点击确定继续添加,查看全部点击取消。")){
                        var url = location.href;
                        if (url.indexOf("city=") == -1) {
                            url = location.href + "&city=" + escape(city)
                        } else {
                            url = url.split("?")[0] + "?SceneID=" + sceneID + "&city=" + escape(city);
                        }                   
                        location.href = url;
                       // window.parent.document.getElementById('divditu_footer').style.display = "block";
                    }else{   */
                    location.href = location.href + "&tab=list";
                    //location.reload();
                    // }
                } else {
                    alertfun("对不起，保存失败，请联系管理员。");

                    return false;
                }
            }
            ajaxGet(url, fun);
        }
        function alertfun(txt) {
            $("#successTip").text(txt).animate({ opacity: '1' }, 10);
            $("#successTip").text(txt).animate({ opacity: '0' }, 6000);
        }

        // 百度地图API功能
        var map = new BMap.Map("allmap");
        var point = new BMap.Point(116.391398, 39.897445);
        map.centerAndZoom(point, 11);
        //鼠标滚轮缩放
        map.enableScrollWheelZoom(true);
        var top_right_navigation = new BMap.NavigationControl();
        map.addControl(top_right_navigation);       // 添加平移缩放控件
        map.addControl(new BMap.ScaleControl());            // 添加比例尺控件
        map.addControl(new BMap.OverviewMapControl());      // 添加缩略地图控件
        map.enableAutoResize();

        var cityName = GetQueryString("city");
        if (!!cityName) {
            map.setCenter(cityName);
        } else {
            function myFun(result) {
                cityName = result.name;
                // map.setCenter(cityName);
                point = new BMap.Point(result.center.lng, result.center.lat);
                map.centerAndZoom(point, 11);
            }
            //IP定位获取当前城市
            var myCity = new BMap.LocalCity();
            myCity.get(myFun);
        }

        var adds = [];

        var lng = document.getElementById("lng").value;
        var lat = document.getElementById("lat").value;
        if (lng != '' && lat != '') {
            point = new BMap.Point(lng, lat);
            zoom = 14
        }

        var marker = new BMap.Marker(point);
        map.addOverlay(marker);
        map.addEventListener("click", function (e) {
            changeMarker(e);
        });

        //清空屏幕上的标记，并重新添加一个标记
        function changeMarker(e) {
            coord = new Array(e.point.lng, e.point.lat);
            map.clearOverlays();
            point = new BMap.Point(e.point.lng, e.point.lat);
            marker = new BMap.Marker(point);
            map.addOverlay(marker);
            document.getElementById("lng").value = e.point.lng;
            document.getElementById("lat").value = e.point.lat;
            // 根据坐标得到地址描述
            myGeo.getLocation(new BMap.Point(e.point.lng, e.point.lat), function (result) {
                if (result) {

                    var ptemp = result.addressComponents.province;
                    document.getElementById("Province").value = ptemp.replace("市", "");
                    set_city(document.getElementById("Province"), document.getElementById("city"));
                    var ctemp = result.addressComponents.city;
                    document.getElementById("city").value = ctemp.replace("市", "").replace("地区", "");
                    var atemp = result.address;
                    document.getElementById("address").value = atemp.replace(ptemp, "").replace(ctemp, "");
                }
            });
        }

        //根据地图上的当前标记对象，清空屏幕上的标记，并重新添加一个标记
        function changeMarkerByMark(e) {
            map.removeOverlay(marker);
            point = new BMap.Point(e.target.getPosition());
            marker = new BMap.Marker(point);
            map.addOverlay(marker);
            document.getElementById("lng").value = e.target.getPosition().lng;
            document.getElementById("lat").value = e.target.getPosition().lat;
            // 根据坐标得到地址描述
            myGeo.getLocation(new BMap.Point(e.target.getPosition().lng, e.target.getPosition().lat), function (result) {
                if (result) {
                    var ptemp = result.addressComponents.province;
                    document.getElementById("Province").value = ptemp.replace("市", "");
                    set_city(document.getElementById("Province"), document.getElementById("city"));
                    var ctemp = result.addressComponents.city;
                    document.getElementById("city").value = ctemp.replace("市", "").replace("地区", "");
                    var atemp = result.address;
                    document.getElementById("address").value = atemp.replace(ptemp, "").replace(ctemp, "");
                }
            });
        }

        var m = [];
        var local = new BMap.LocalSearch(map, {
            renderOptions: { map: map }, //panel :'search_list'},
            onMarkersSet: function (results) {
                if (local.getStatus() == BMAP_STATUS_SUCCESS) {
                    m = [];
                    for (var i in results) {
                        m[i] = results[i].marker;
                        m[i].addEventListener('infowindowopen', function (e) {
                            changeMarkerByMark(e);
                        });
                    }
                }
            }
        });


        function citychange(city) {
            cityName = city.value;
            map.setCenter(cityName);
            Latitude = "";
            Longitude = "";
        }

        function myFun(result) {
            cityName = result.name;
            map.setCenter(cityName);
            //获取指定城市的网点
            //document.getElementById("curCity").innerHTML = cityName;
            var city = encodeURIComponent(cityName);
            var url = "/As/getAddress?city=" + city;
            var fun = function (ret) {
                if (!ret) {
                    alertfun("对不起，当前城市没有网点。");
                    return false;
                }
                adds = ret.split('$');
                bdGEO();
            }
            ajaxGet(url, fun);
        }


        //IP定位获取当前城市
        // var myCity = new BMap.LocalCity();
        // myCity.get(myFun);

        ///////////批量地址解析
        var index = 0;
        var myGeo = new BMap.Geocoder();

        function addressSearch() {
            var add = document.getElementById("address").value;
            var city = document.getElementById("city").value;
            if (!city) {
                alertfun("请先选择省份和城市。");
                return false;
            }
            if (!add) {
                alertfun("请先输入详细地址。");
                return false;
            }
            // 将地址解析结果显示在地图上,并调整地图视野
            myGeo.getPoint(add, function (point) {
                if (point) {
                    map.centerAndZoom(point, 16);
                    map.addOverlay(new BMap.Marker(point));
                    Latitude = point.lat;
                    document.getElementById("lat").value = Latitude;
                    Longitude = point.lng;
                    document.getElementById("lng").value = Longitude;
                } else {
                    alertfun("您选择地址没有解析到结果!");
                }
            }, cityName);
        }
        function bdGEO() {
            var add = adds[index];
            !!add && geocodeSearch(add.split('#')[0]);
            index++;
        }

        function geocodeSearch(add) {
            if (index < adds.length) {
                setTimeout(window.bdGEO, 400);
            }
            myGeo.getPoint(add, function (point) {

                if (point) {
                    var address = new BMap.Point(point.lng, point.lat);

                    addMarker(address, add);
                }
            }, cityName);
        }
        // 编写自定义函数,创建标注
        function addMarker(point, content) {
            var marker1 = new BMap.Marker(point);
            map.addOverlay(marker1);
            addClickHandler(content, marker1);
        }
        function addClickHandler(content, marker) {
            marker.addEventListener("click", function (e) {
                openInfo(content, e)
            }
		);
        }
        var opts = {
            width: 250,     // 信息窗口宽度
            height: 90,     // 信息窗口高度
            enableMessage: false,
            title: "信息窗口"
        };
        function openInfo(content, e) {
            var p = e.target;
            var point = new BMap.Point(p.getPosition().lng, p.getPosition().lat);
            opts.title = content.split("(")[1].split(")")[0];
            var address = content.split("(")[0];
            var tel = getTel(content);
            var infoWindow = new BMap.InfoWindow("地址：" + address + tel, opts);  // 创建信息窗口对象 
            map.openInfoWindow(infoWindow, point); //开启信息窗口
        }
        function getTel(content) {
            var tel = "";
            for (var i = 0; i < adds.length; i++) {
                if (adds[i].indexOf(content) > -1) {
                    if (adds[i].split("#").length > 0) {
                        tel = "\n\t<br/>" + adds[i].split("#")[1];
                    }
                }
            }
            return tel;
        }


	</script>
</html>
